package com.ce.pms.log4ce;

import java.util.Map;

import org.aspectj.lang.JoinPoint;

import com.ce.component.log4ce.aop.constructor.support.AbstractBizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.BizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.OriginalObjectHolder;
import com.ce.component.log4ce.aop.parser.BizLogParser;
import com.ce.pms.house.model.HousePlan;
import com.ce.pms.house.vo.FlatVO;

public class HouseEditHandler extends AbstractBizDescriptionHandler implements BizDescriptionHandler {

	private Log4ceHelper log4ceHelper = Log4ceHelper.getInstance();
	@Override
	public Map<String, Object> getNamedParametersMap(JoinPoint joinPoint, Object returnValue, BizLogParser logParser) {

		Map<String,Object> map = logParser.getLogArguments(joinPoint);

		//old info
		FlatVO housevo =  (FlatVO)OriginalObjectHolder.ORIGINAL_OBJECTS.get().get("oldHouseInfo");
		map.put("oldHouseNumber", housevo.getHouseNumber());
		map.put("oldHouseType", housevo.getHousePlanName());
		map.put("oldStandard", housevo.getDeliveryLimitationName());
		map.put("oldBuildSize", housevo.getBuildSize());
		map.put("oldInnerSize", housevo.getInnerSize());
		map.put("oldPublicSize", housevo.getPublicSize());

		//new info
		FlatVO flatvo = (FlatVO)returnValue;

		Long planId = flatvo.getHousePlanId();
		HousePlan housePlan = log4ceHelper.getHouseService().getHousePlanByPlanId(planId);

		FlatVO house = log4ceHelper.getFlatVOById(flatvo.getKeyword());

		map.put("newHouseNumber", flatvo.getHouseNumber());
		map.put("newHouseType", housePlan.getName());
		map.put("newStandard", flatvo.getDeliveryLimitationName());
		//业务中不能修改建筑面积,套内面积,公摊面积
		map.put("newBuildSize", house.getBuildSize());
		map.put("newInnerSize", house.getInnerSize());
		map.put("newPublicSize", house.getPublicSize());

		map.putAll(logParser.getLogStaticContents(joinPoint));
		return map;
	}
}
